# coding:utf-8
# filename:yangsy.py

from selenium import webdriver
import time
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import Select

file_path = 'D:/Day08/Day51/selenium.html'
driver = webdriver.Chrome()
driver.get(file_path)

# 最大化窗口：
driver.maximize_window()

# 获取元素并传值：
driver.find_element_by_css_selector("div#signup input[name='username']").send_keys('rabbit')
driver.find_element_by_css_selector("div#signup input[name='password']").send_keys('love')
time.sleep(2)
Select(driver.find_element_by_css_selector("div#signup select[name='city']")).select_by_value("sz")
time.sleep(2)
driver.find_element_by_xpath('//*[@id="signup"]/form/input[3]').click()
time.sleep(3)

# 显示等待注册成功：
sign = WebDriverWait(driver,10,0.5).until(
    lambda x: x.find_element_by_css_selector('div#signup').text == "注册成功")

driver.close()
driver.quit()